package com.tbh.ioc.container.beanFactory;

import com.tbh.ioc.bean.HelloWorld;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

public class BeanFactoryMain {
    public static void main(String[] args) {
//        String path1 =  Thread.currentThread().getContextClassLoader().getResource("").getPath();
//        System.out.println("root path: " + path1);
//
//        String path2 = System.getProperty("/");
//        System.out.println("root path: " + path2);
//
//        String path3 = BeanFactoryMain.class.getClass().getResource("/").getPath();
//        System.out.println("root path: " + path3);
//
//        String path4 = BeanFactoryMain.class.getClass().getClassLoader().getResource("").getPath();
//        System.out.println("root path: " + path4);


        // ClassPathResource 获取resources目录下
        XmlBeanFactory xmlBeanFactory = new XmlBeanFactory(new ClassPathResource("Beans.xml"));
        HelloWorld helloWorld = (HelloWorld) xmlBeanFactory.getBean("helloWorld");
        helloWorld.setMessage("XmlBeanFactory getBean");
        String message = helloWorld.getMessage();
        System.out.println(message);
    }
}
